<?php
    include '../connectDatabase.php';

    include_once('../is_login.php');
    session_start();
    if(!is_login()){
        echo "<script>alert('请登录系统后访问!');window.location.href='http://localhost:8080/PHP-NEWS-RELEASE-SYSTEM/Application/User/Page/login.php'</script>";
    }
    
    $ID = $_SESSION['userid'];
    //$ID = $_GET['code'];

    $sqlshow = "select * from users where user_id='$ID'";
    $result = mysqli_query($conn,$sqlshow);
    $records = array();
    while($record = mysqli_fetch_array($result))
    {
        $records [] = $record;
    }
    foreach($records as $row) :
        $sex=$row['user_sex'];
        $username=$row['user_name'];
        $password=$row['user_password'];
        $email=$row['user_email'];
    endforeach;
    
    $close = @mysqli_close($conn);
?>

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>修改个人信息</title>
    <link rel="stylesheet" href="../SignUpStyle.css">
    <link href="https://fonts.googleapis.com/css?familymPermanent+Marker" >
</head>    
<body>
<div class="sign-div">
    <form class="" action="../Action/user_mondify_action.php" method="post" name="input" onSubmit="return check(this);">
        <h1>修改</h1>
        <input class="sign-text" type="text" placeholder="用户名" name="username" value= "<?php echo $username;?>">
        <input class="sign-text" type="password" placeholder="密码" name="passwd" value= "<?php echo $password;?>">
        <input class="sign-text" type="password" placeholder="确认密码" name="repasswd" value= "<?php echo $password;?>">
        <input class="sign-text" type="email" placeholder="邮箱" name="email" value= "<?php echo $email;?>">
        <select class="beauty-select" name="sex" size="1">
        <?php
                                 
            if(strcmp($sex,"保密")==0)    {               
                echo "<option value='保密'>保密 </option><option value='男' >男 </option><option value='女'>女 </option>";               
            }else if(strcmp($sex,"男")==0){
                echo "<option value='男' >男 </option><option value='保密'>保密 </option><option value='女'>女 </option>";
            }else{
                echo "<option value='女'>女 </option><option value='男' >男 </option><option value='保密'>保密 </option>";
            }                   
        ?>
        </select>
        <input class="sign-btn" type="submit" value="修改">
    </form>
</div>
</body>
</html>